﻿namespace ScrumLite.Data
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using ScrumLite.Data;

    public class UserStore : IUserStore
    {
        public Education[] RetrieveUserEducation(string user)
        {
            using (ScrumLiteDataContext ctx = new ScrumLiteDataContext())
            {
                var education = (from ed in ctx.Educations
                                 where ed.samAccountName == user
                                 select ed).ToArray();

                return education;
            }
        }

        public Ability[] RetrieveUserAbilities(string user)
        {
            using (ScrumLiteDataContext ctx = new ScrumLiteDataContext())
            {
                var abilities = (from ua in ctx.UserAbilities
                                 from a in ctx.Abilities
                                 where ua.samAccountName == user
                                 where a.id == ua.fk_ability
                                 select a).ToArray();

                return abilities;
            }
        }
    }
}
